﻿using System;
using System.Web;
using Yglu.BusinessLayer.Entities;

namespace Yglu.WebAdmin
{
	public class SessionManager
	{
		#region Properties

		public static String LastLogMessage
		{
			get
			{
				Object s = HttpContext.Current.Session["LastLogMessage"];

				if (s != null)
				{
					return s.ToString();
				}

				return String.Empty;
			}
			set
			{
				HttpContext.Current.Session.Add("LastLogMessage", value);
			}
		}

		public static User LoggedUser
		{
			get
			{
				return new User(1);

				Object s = HttpContext.Current.Session["LoggedUser"];

				if (s != null)
				{
					return s as User;
				}

				return null;
			}
			set
			{
				HttpContext.Current.Session.Add("LoggedUser", value);
			}
		}

		public static Store LoggedStore
		{
			get
			{
				Object s = HttpContext.Current.Session["LoggedStore"];

				if (s != null)
				{
					return s as Store;
				}

				if (LoggedUser != null)
				{
					return LoggedUser.Store;
				}

				return null;
			}
			set
			{
				HttpContext.Current.Session.Add("LoggedStore", value);
			}
		}

		#endregion
	}
}